package properties;
import java.io.*;
import java.util.*;

public class Greeting3
{
     String message;

           public Greeting3()
          {

          }

     public void setMessage()
     {
     //create an instance of properties class

     Properties props = new Properties();

     //try retrieve data from file
     //catch exception in case properties file does not exist

               try {

               props.load(new FileInputStream("C:/workspace/TUTO/src/message.properties"));

               message = props.getProperty("message");

             //If value of message variable is null assign default value "Hello World"

             if(message==null)
               {
               message=new String("Hello World!");
               }

     System.out.println(message);

     }

     //catch exception in case properties file does not exist

     catch(IOException e)
     {
     e.printStackTrace();
     }
   }

     public static void main(String[] args)
     {
     //create an instance of Greeting3 class

     Greeting3 gr = new Greeting3();

     //call the setMessage() method of the Greeting3 class

     gr.setMessage();

     }

   }